<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>权限中心</title>
    <link href="/common/js/bootstrap-3.0.0/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <style type="text/css">
        html, body {
            padding-top: 25px;
            padding-bottom: 40px;
        }

        li a {
            font-size: 12px;
        }
    </style>
    <script type="text/javascript" src="/common/js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="/common/js/bootstrap-3.0.0/js/bootstrap.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#navBar > ul > li.dropdown").each(function () {
                var $obj = $(this);
                $obj.mouseover(function () {
                    $("#navBar > ul > li.dropdown").removeClass("open");
                    $obj.addClass("open");
                });

                $obj.find("ul").mouseout(function () {
                    $obj.removeClass("open");
                });
            });

//            window.onresize = function () {
//                autoIFrame();
//            }

            setInterval(autoIFrame, 1000);
        });

        //每10秒判断一次是否登录
        function checkLogin() {
            $.ajax({
                type: "GET",
                url: "/checkLogin.json?r=" + Math.random(),
                success: function (data) {
                    if (data.status == 0) {
                        location.href = "/login";
                    }
                }
            });
        }

        /**
         * 设置iframe自适应高度
         * @param obj
         * @constructor
         */
        function setIFrameHeight(obj) {
            var win = obj;
            if (document.getElementById) {
                if (win && !window.opera) {
                    if (win.contentDocument && win.contentDocument.body.scrollHeight) {
                        win.height = win.contentDocument.body.scrollHeight;
                    } else if (win.document && win.document.body.scrollHeight) {
                        win.height = win.document.body.scrollHeight;
                    }

                    win.height < document.documentElement.clientHeight - 50 ? win.height = document.documentElement.clientHeight - 50 : true;
                }
            }
        }

        function autoIFrame() {
            alert("tt");
            var obj = document.getElementById("rightFrameName");
            setIFrameHeight(obj);
        }

        function back2top() {
            window.scrollTo(0, 0);
        }
    </script>
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top">
    <div class="container">
        <div id="navBar" class="navbar-collapse collapse navbar-responsive-collapse">
            <ul class="nav navbar-nav">
            <#if menuList??>
                <#list menuList as menu>
                    <#if menu.list?? && menu.list?size gt 0>
                        <li class="dropdown">
                            <a data-toggle="dropdown" class="dropdown-toggle"
                               href="${menu.menuUrl!"javascript:void(0);"}">${menu.menuName}<b class="caret"></b></a>
                            <ul class="dropdown-menu">
                                <#list menu.list as list>
                                    <li><a href="${list.menuUrl!"javascript:void(0);"}"
                                           target="main">${list.menuName}</a></li>
                                </#list>
                            </ul>
                        </li>
                    <#else>
                        <li>
                            <a href="${menu.menuUrl!"javascript:void(0);"}">${menu.menuName}</a>
                        </li>
                    </#if>
                </#list>
            </#if>
            </ul>

        <#if username??>
            <ul class="nav navbar-nav navbar-right">
                <li class="dropdown">
                    <a data-toggle="dropdown" class="dropdown-toggle" href="#">${username} <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                        <#--<li><a href="/user/userCenter" target="main">个人中心</a></li>-->
                        <#--<li class="divider"></li>-->
                        <li><a href="/logout">注销</a></li>
                    </ul>
                </li>
            </ul>
        </#if>
        </div>
    </div>
</div>
<iframe id="showIFrame" name="main" frameborder="0" width="100%"
        scrolling="no" style="overflow: visible;" onLoad="setIFrameHeight(this);"
        src="/welcome">
</iframe>
</body>
</html>
